#! /usr/bin/env python
# Pango is a library for rendering internationalized texts
import pango

import gtk
import gtk.glade

import logging

class MindAge:
	def __init__(self, runaslib=True):
		# Load Glade XML
		self.xml = gtk.glade.XML("glade/mindage.glade")
		
		# Get Window
		self.w = self.xml.get_widget('window1')
		self.w.connect("delete_event", gtk.main_quit)
		
		# Get Windows child
		self.w_child = self.w.get_child()
		
		# Get our Label
		#self.label = self.xml.get_widget('label1')
		
		# Connect functions to Buttons
		self.correctbutton = self.xml.get_widget('CorrectButton')
		self.correctbutton.connect('clicked', self.correct_clicked)

		self.incorrectbutton = self.xml.get_widget('IncorrectButton')
		self.incorrectbutton.connect('clicked', self.incorrect_clicked)

		self.questionsview = self.xml.get_widget('QuestionsView')
		self.scoresview = self.xml.get_widget('ScoresView')

		tagtable=gtk.TextTagTable()
		self.texttag=gtk.TextTag('default')
		self.texttag.set_property('size-points',80)
		tagtable.add(self.texttag)

		self.questionsbuffer=gtk.TextBuffer(tagtable)
		self.scoresbuffer=gtk.TextBuffer(tagtable)
		self.questionsbuffer.insert_with_tags(self.questionsbuffer.get_end_iter(), '1+2=4\n1+2=4\n1+2=4\n1+2=4\n1+2=4\n1+2=4\n1+2=4\n1+2=4\n1+2=4\n1+2=4\n', self.texttag)
		self.scoresbuffer.insert_with_tags(self.scoresbuffer.get_end_iter(), 'O\nX\nO\nX\nO\nX\nO\nX\nO\nX\n', self.texttag)

		self.questionsview.set_buffer(self.questionsbuffer)
		self.scoresview.set_buffer(self.scoresbuffer)

		# self.widget will be attached to the Activity
		# This can be any GTK widget except a window
		self.widget = self.w_child

		if not runaslib:
			self.w.show_all()
			gtk.main()

	def correct_clicked(self, *args):
		logging.info("Correct Button Clicked!")

	def incorrect_clicked(self, *args):
		logging.info("Incorrect Button Clicked!")
				
if __name__ == '__main__':
	gtktest(False)

